package lecture07.account;

class AccountBook{
    private String accountName;
    private double income;
    private double outcome;
    AccountBook(String accountName,double income,double outcome){
        this.accountName=accountName;
        if (income < 0 || outcome < 0) {
            System.out.println("输入有误");
        }else {
            this.income=income;
            this.outcome=outcome;
        }
    }
    public double compute() {
        return income-outcome;
    }
    public void printAccountBook() {
        System.out.println("*****************");
        System.out.println(accountName);
        System.out.println("收入" + income);
        System.out.println("支出" + outcome);
        System.out.println("余额" + compute());
        System.out.println("*****************");
    }
}

public class AccountBookTest {
    public static void main(String[] args) {
        AccountBook accountBook1 = new AccountBook("张三", 30, 10);
        accountBook1.printAccountBook();
        AccountBook accountBook2 = new AccountBook("张三", -30, 10);
        accountBook2.printAccountBook();
    }
}
